package com.gupao.proxydemo.jdkdemo;

import com.gupao.proxydemo.Person;
import lombok.extern.slf4j.Slf4j;
import sun.misc.ProxyGenerator;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.Proxy;

@Slf4j
public class JDKProxyTest {
    public static void main(String[] args) {
        Person p = (Person) new JDKMeipo().getInstance(new TargetPerson());
//        log.info("jdk动态代理类：{}",p.getClass());
        System.out.println(p);
        p.findLove();

//        byte [] bytes = ProxyGenerator.generateProxyClass("$Proxy0",new Class[]{Person.class});
//        try {
//            FileOutputStream fos = new FileOutputStream("/Users/wangenji/Documents/$Proxy0.class");
//            fos.write(bytes);
//            fos.close();
//        } catch (Exception e) {
//            e.printStackTrace();
//        }

    }
}
